--[[

LPS_GUI.lua

This lua file handles the GUI options screen functions.

]]

--[[

Split this stuff out when I get a chance

]]

--[[
function: LGUI_CheckButton(myFrame, myFunction, myState, myText)

Variables:
myFrame		= your created frame
myFunction	= Function to run when the button is pressed
--myText		= Text for the check button
myState		= Variable to check true/false for checkbox state.

Details:
Frame should already have been created, eg:-
local LPS_GUI_SortDirection = CreateFrame("CheckButton", "LPS_GUI_SortDirection", LPS_GUI_OPTIONS_SC, "UICheckButtonTemplate");

Once created, you need to set _where_ the frame is, eg:-
myFrame:SetPoint("TOPLEFT", LPS_GUI_OPTIONS_SC, "TOPLEFT", 0, -10);

]]
function LGUI_CheckButton(myFrame, myFunction, myState, myText )
	myFrame:ClearAllPoints();
	if (myState == false) then
		myFrame:SetChecked(false);
	else
		myFrame:SetChecked(true);
	end
	myFrame:SetScript("OnClick", myFunction);
--	myFrameText:SetText(myText);
end

function LGUI_DropDown(myFrame, myFunction, myChoice, myOptions)
	if (myChoice == nil) then
		myChoice = 0;
	end

	local function OnClick(self)
		UIDropDownMenu_SetSelectedID(myFrame, self:GetID());
		myFunction(self:GetID());
	end

	local function initialize(self, level)
		--local info = UIDropDownMenu_CreateInfo();
		for k,v in pairs(myOptions) do
			local info	= UIDropDownMenu_CreateInfo();
			info.text	= v;
			info.value	= v;
			info.func	= OnClick;
			UIDropDownMenu_AddButton(info, level);
		end
	end

--	myFrame:ClearAllPoints();
--	myFrame:SetScript("OnClick", myFunction);
--	myFrameText:SetText(myText);

	myFrame:ClearAllPoints()
--	myFrame:SetPoint("CENTER", 0, 0)
	myFrame:Show()
	
	UIDropDownMenu_Initialize(myFrame, initialize);
	UIDropDownMenu_SetWidth(myFrame, 140);
	UIDropDownMenu_SetButtonWidth(myFrame, 164);
	UIDropDownMenu_SetSelectedID(myFrame, (myChoice + 1));
	UIDropDownMenu_JustifyText(myFrame, "LEFT");
	
end

function LGUI_AddDescLeft(myFrame, myText)
	local leftDesc = myFrame:CreateFontString("leftDesc");
	leftDesc:ClearAllPoints();
	leftDesc:SetFontObject(GameFontNormal);
	leftDesc:SetJustifyH("RIGHT");
	leftDesc:SetJustifyV("TOP");
	--leftDesc:SetPoint("TOPRIGHT", myFrame, "TOPLEFT", 5, -5);
	leftDesc:SetPoint("TOPRIGHT", myFrame, "TOPLEFT", 5, -7);
	leftDesc:SetText(myText);
	leftDesc:Show();
end



--[[
function: LGUI_Header(myFrame, myText)

Variables:
myFrame		= Created frame
myText		= Text for the check button

Details:
Frame should already have been created, eg:-
local LPS_GUI_SortDirection = CreateFrame("CheckButton", "LPS_GUI_SortDirection", LPS_GUI_OPTIONS_SC, "UICheckButtonTemplate");

Once created, you need to set _where_ the frame is, eg:-
myFrame:SetPoint("TOPLEFT", LPS_GUI_OPTIONS_SC, "TOPLEFT", 0, -10);

]]
function LGUI_Header(myFrame, myText)
	myFrame:ClearAllPoints();
--	myFrameText:SetText(myText);
	
	--local frame = CreateFrame("Frame", nil, UIParent);
	--myFrame:Hide();

	label = myFrame:CreateFontString(nil, "BACKGROUND", "GameFontNormal");
	label:SetPoint("TOP");
	label:SetPoint("BOTTOM");
	label:SetJustifyH("CENTER");
	label:SetText(myText);
	label:Show();

	left = myFrame:CreateTexture(nil, "BACKGROUND");
	left:SetHeight(8);
	left:SetPoint("LEFT", 3, 0);
	left:SetPoint("RIGHT", label, "LEFT", -5, 0);
	left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border");
	left:SetTexCoord(0.81, 0.94, 0.5, 1);
	left:Show();

	right = myFrame:CreateTexture(nil, "BACKGROUND");
	right:SetHeight(8);
	right:SetPoint("RIGHT", -3, 0);
	right:SetPoint("LEFT", label, "RIGHT", 5, 0);
	right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border");
	right:SetTexCoord(0.81, 0.94, 0.5, 1);
	right:Show();

	myFrame:Show();
end


--[[
End of stuff to split out
]]

-- Function: Set the settings on the GUI window to the current settings
function LPS_GUI_UpdateValues()
	-- Update values for the "Special" sort types
	UIDropDownMenu_SetSelectedID(LPS_GUI_SBItemsPack,	LPS_Config.sbitemPack		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_SBItemsPack, LPS_GUI_Packs[LPS_Config.sbitemPack		+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_QuestItemsPack,	LPS_Config.questPack		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_QuestItemsPack, LPS_GUI_Packs[LPS_Config.questPack	+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_HerbSort,		LPS_Config.herbsort		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_HerbSort, LPS_GUI_Packs[LPS_Config.herbsort		+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_LeatherSort,	LPS_Config.leathersort		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_LeatherSort, LPS_GUI_Packs[LPS_Config.leathersort	+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_MineralSort,	LPS_Config.mineralsort		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_MineralSort, LPS_GUI_Packs[LPS_Config.mineralsort	+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_ClothSort,		LPS_Config.clothsort		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_ClothSort, LPS_GUI_Packs[LPS_Config.clothsort		+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_GemSort,		LPS_Config.gemsort		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_GemSort, LPS_GUI_Packs[LPS_Config.gemsort		+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_ConsumableSort,	LPS_Config.consumablesort	+ 2);
	UIDropDownMenu_SetText(LPS_GUI_ConsumableSort, LPS_GUI_Packs[LPS_Config.consumablesort	+ 2]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_TradeSort,		LPS_Config.tradesort		+ 2);
	UIDropDownMenu_SetText(LPS_GUI_TradeSort, LPS_GUI_Packs[LPS_Config.tradesort		+ 2]);

	-- Update values for the various worn packs
	UIDropDownMenu_SetSelectedID(LPS_GUI_SortPack0,		LPS_Config.pack0 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortPack0, LPS_GUI_SortTypes[LPS_Config.pack0 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortPack1,		LPS_Config.pack1 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortPack1, LPS_GUI_SortTypes[LPS_Config.pack1 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortPack2,		LPS_Config.pack2 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortPack2, LPS_GUI_SortTypes[LPS_Config.pack2 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortPack3,		LPS_Config.pack3 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortPack3, LPS_GUI_SortTypes[LPS_Config.pack3 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortPack4,		LPS_Config.pack4 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortPack4, LPS_GUI_SortTypes[LPS_Config.pack4 + 1]);


	-- Update values for the bank and bank packs
	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack0,	LPS_Config.packb0 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack0, LPS_GUI_SortTypes[LPS_Config.packb0 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack1,	LPS_Config.packb1 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack1, LPS_GUI_SortTypes[LPS_Config.packb1 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack2,	LPS_Config.packb2 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack2, LPS_GUI_SortTypes[LPS_Config.packb2 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack3,	LPS_Config.packb3 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack3, LPS_GUI_SortTypes[LPS_Config.packb3 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack4,	LPS_Config.packb4 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack4, LPS_GUI_SortTypes[LPS_Config.packb4 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack5,	LPS_Config.packb5 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack5, LPS_GUI_SortTypes[LPS_Config.packb5 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack6,	LPS_Config.packb6 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack6, LPS_GUI_SortTypes[LPS_Config.packb6 + 1]);

	UIDropDownMenu_SetSelectedID(LPS_GUI_SortBankPack7,	LPS_Config.packb7 + 1);
	UIDropDownMenu_SetText(LPS_GUI_SortBankPack7, LPS_GUI_SortTypes[LPS_Config.packb7 + 1]);

end

function LPS_RegConfig()
	-- Create main frame for information text
	LPS_GUI	= CreateFrame("FRAME", "LPS_GUI");
	LPS_GUI.name	= LPS_DESC;
	LPS_GUI.refresh	= LPS_GUI_UpdateValues;
	InterfaceOptions_AddCategory(LPS_GUI);

	-- Options Header
	LPS_GUI_Header = LPS_GUI:CreateFontString(nil, "OVERLAY");
	LPS_GUI_Header:SetFontObject(GameFontNormalLarge);
	LPS_GUI_Header:SetJustifyH("LEFT");
	LPS_GUI_Header:SetJustifyV("TOP");
	LPS_GUI_Header:ClearAllPoints();
	LPS_GUI_Header:SetPoint("TOPLEFT", 10, -10);
	LPS_GUI_Header:SetText(LPS_DESC);

	-- Version
	LPS_GUI_Version = LPS_GUI:CreateFontString(nil, "OVERLAY")
	LPS_GUI_Version:SetFontObject(GameFontNormalLarge)
	LPS_GUI_Version:SetJustifyH("LEFT")
	LPS_GUI_Version:SetJustifyV("TOP")
	LPS_GUI_Version:ClearAllPoints()
	LPS_GUI_Version:SetPoint("TOPLEFT", LPS_GUI_Header,"BOTTOMLEFT", 0, 0)
	LPS_GUI_Version:SetText("Version "..LPS_VERS_NUM)

	-- Scroll Frame + ScrollChild
	LPS_GUI_OPTIONS = CreateFrame("ScrollFrame", "LPS_GUI_OPTIONS", LPS_GUI, "UIPanelScrollFrameTemplate");
	LPS_GUI_OPTIONS_SC = CreateFrame("Frame", "TestScrollChild", LPS_GUI_OPTIONS);
	LPS_GUI_OPTIONS:SetScrollChild(LPS_GUI_OPTIONS_SC);
	LPS_GUI_OPTIONS:SetPoint("TOPLEFT", LPS_GUI, "TOPLEFT", 5, -45);
	LPS_GUI_OPTIONS_SC:SetPoint("TOPLEFT", "LPS_GUI_OPTIONS", "TOPLEFT", 0, 0);
	LPS_GUI_OPTIONS:SetWidth(580);
	LPS_GUI_OPTIONS:SetHeight(510);
	LPS_GUI_OPTIONS_SC:SetWidth(580);
	LPS_GUI_OPTIONS_SC:SetHeight(600);
	LPS_GUI_OPTIONS:SetHorizontalScroll(0);
	LPS_GUI_OPTIONS:SetVerticalScroll(0);
	LPS_GUI_OPTIONS:EnableMouse(true);
	LPS_GUI_OPTIONS:Show();
	LPS_GUI_OPTIONS_SC:Show();

--[[
	Need to put a header in here somehow
	
	Options below are for the entire addon.
	
	]]
	
	-- Sort Direction
	LPS_GUI_SortDirection = CreateFrame("CheckButton", "LPS_GUI_SortDirection", LPS_GUI_OPTIONS_SC, "UICheckButtonTemplate");
	LGUI_CheckButton(LPS_GUI_SortDirection, LPS_GUI_ChangeSortDirection, LPS_Config.lowestfirst);
	LPS_GUI_SortDirectionText:SetText("Sort items by smallest value first");
	LPS_GUI_SortDirection:SetPoint("TOPLEFT", LPS_GUI_OPTIONS_SC, "TOPLEFT", 0, -30);

	-- Quest Items Sorting
	LPS_GUI_SBItemsPack = CreateFrame("Frame", "LPS_GUI_SBItemsPack", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SBItemsPack, LPS_GUI_SBItemsPackSelect, (LPS_Config.sbitemPack + 1), LPS_GUI_Packs);
	LPS_GUI_SBItemsPack:SetPoint("TOPLEFT", LPS_GUI_SortDirection, "TOPLEFT", 180, -50);
	LGUI_AddDescLeft(LPS_GUI_SBItemsPack, "Soulbound Item Sort Pack -");

	-- Quest Items Sorting
	LPS_GUI_QuestItemsPack = CreateFrame("Frame", "LPS_GUI_QuestItemsPack", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_QuestItemsPack, LPS_GUI_QuestItemsPackSelect, (LPS_Config.questPack + 1), LPS_GUI_Packs);
	LPS_GUI_QuestItemsPack:SetPoint("TOPLEFT", LPS_GUI_SBItemsPack, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_QuestItemsPack, "Quest Item Sort Pack -");

	-- Herb Sorting
	LPS_GUI_HerbSort = CreateFrame("Frame", "LPS_GUI_HerbSort", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_HerbSort, LPS_GUI_ChangeHerbSort, (LPS_Config.herbsort + 1), LPS_GUI_Packs);
	LPS_GUI_HerbSort:SetPoint("TOPLEFT", LPS_GUI_QuestItemsPack, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_HerbSort, "Herb Sort Pack -");

	-- Leather Sorting
	LPS_GUI_LeatherSort = CreateFrame("Frame", "LPS_GUI_LeatherSort", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_LeatherSort, LPS_GUI_ChangeLeatherSort, (LPS_Config.leathersort + 1), LPS_GUI_Packs);
	LPS_GUI_LeatherSort:SetPoint("TOPLEFT", LPS_GUI_HerbSort, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_LeatherSort, "Leather Sort Pack -");

	-- Minerals Sorting
	LPS_GUI_MineralSort = CreateFrame("Frame", "LPS_GUI_MineralSort", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_MineralSort, LPS_GUI_ChangeMineralSort, (LPS_Config.mineralsort + 1), LPS_GUI_Packs);
	LPS_GUI_MineralSort:SetPoint("TOPLEFT", LPS_GUI_LeatherSort, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_MineralSort, "Minerals Sort Pack -");

	-- Cloth Sorting
	LPS_GUI_ClothSort = CreateFrame("Frame", "LPS_GUI_ClothSort", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_ClothSort, LPS_GUI_ChangeClothSort, (LPS_Config.clothsort + 1), LPS_GUI_Packs);
	LPS_GUI_ClothSort:SetPoint("TOPLEFT", LPS_GUI_MineralSort, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_ClothSort, "Cloth Sort Pack -");

	-- Gem Sorting
	LPS_GUI_GemSort = CreateFrame("Frame", "LPS_GUI_GemSort", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_GemSort, LPS_GUI_ChangeGemSort, (LPS_Config.gemsort + 1), LPS_GUI_Packs);
	LPS_GUI_GemSort:SetPoint("TOPLEFT", LPS_GUI_ClothSort, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_GemSort, "Gem Sort Pack -");

	-- Consumable Sorting
	LPS_GUI_ConsumableSort = CreateFrame("Frame", "LPS_GUI_ConsumableSort", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_ConsumableSort, LPS_GUI_ChangeConsumableSort, (LPS_Config.consumablesort + 1), LPS_GUI_Packs);
	LPS_GUI_ConsumableSort:SetPoint("TOPLEFT", LPS_GUI_GemSort, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_ConsumableSort, "Consumables Sort Pack -");

	-- Other Trade Goods Sorting
	LPS_GUI_TradeSort = CreateFrame("Frame", "LPS_GUI_TradeSort", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_TradeSort, LPS_GUI_ChangeTradeSort, (LPS_Config.tradesort + 1), LPS_GUI_Packs);
	LPS_GUI_TradeSort:SetPoint("TOPLEFT", LPS_GUI_ConsumableSort, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_TradeSort, "Other Trade Goods Sort Pack -");

--[[
	TODO:  Add Custom Sorting Options

	-- Custom Sort Style 1
	LPS_GUI_CustomSort1 = CreateFrame("Frame", "LPS_GUI_CustomSort1", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_CustomSort1, LPS_GUI_ChangeCustomSort1, (LPS_Config.customsort1 + 1), LPS_GUI_Packs);
	LPS_GUI_CustomSort1:SetPoint("TOPLEFT", LPS_GUI_ClothSort, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_CustomSort1, "Custom Sort 1 Pack -");

	-- Custom Sort Style 2
	LPS_GUI_CustomSort2 = CreateFrame("Frame", "LPS_GUI_CustomSort2", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_CustomSort2, LPS_GUI_ChangeCustomSort2, (LPS_Config.customsort1 + 1), LPS_GUI_Packs);
	LPS_GUI_CustomSort2:SetPoint("TOPLEFT", LPS_GUI_CustomSort1, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_CustomSort2, "Custom Sort 1 Pack -");
]]	
	
	--[[
	
	Need to put a header in here somehow
	
	Options below are for the regular worn packs.
	
	]]

--[[	
	-- Blizzard has removed the keyring from the game, cutting option from GUI
	-- Keyring Sort Style
	LPS_GUI_SortKeyRing = CreateFrame("Frame", "LPS_GUI_SortKeyRing", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortKeyRing, LPS_GUI_ChangeSortKeyRing, LPS_Config.keyring, LPS_GUI_SortTypes);
	LPS_GUI_SortKeyRing:SetPoint("TOPLEFT", LPS_GUI_TradeSort, "TOPLEFT", 0, -50);
	LGUI_AddDescLeft(LPS_GUI_SortKeyRing, "Keyring Sort Style -");
]]
	
	-- Backpack Sort Style
	LPS_GUI_SortPack0 = CreateFrame("Frame", "LPS_GUI_SortPack0", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortPack0, LPS_GUI_ChangeSortPack0, LPS_Config.pack0, LPS_GUI_SortTypes);
	LPS_GUI_SortPack0:SetPoint("TOPLEFT", LPS_GUI_TradeSort, "TOPLEFT", 0, -50);
	LGUI_AddDescLeft(LPS_GUI_SortPack0, "Backpack Sort Style -");

	-- Sort Style for Pack 1
	LPS_GUI_SortPack1 = CreateFrame("Frame", "LPS_GUI_SortPack1", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortPack1, LPS_GUI_ChangeSortPack1, LPS_Config.pack1, LPS_GUI_SortTypes);
	LPS_GUI_SortPack1:SetPoint("TOPLEFT", LPS_GUI_SortPack0, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortPack1, "Pack 1 Sort Style -");

	-- Sort Style for Pack 2
	LPS_GUI_SortPack2 = CreateFrame("Frame", "LPS_GUI_SortPack2", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortPack2, LPS_GUI_ChangeSortPack2, LPS_Config.pack2, LPS_GUI_SortTypes);
	LPS_GUI_SortPack2:SetPoint("TOPLEFT", LPS_GUI_SortPack1, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortPack2, "Pack 2 Sort Style -");

	-- Sort Style for Pack 3
	LPS_GUI_SortPack3 = CreateFrame("Frame", "LPS_GUI_SortPack3", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortPack3, LPS_GUI_ChangeSortPack3, LPS_Config.pack3, LPS_GUI_SortTypes);
	LPS_GUI_SortPack3:SetPoint("TOPLEFT", LPS_GUI_SortPack2, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortPack3, "Pack 3 Sort Style -");

	-- Sort Style for Pack 4
	LPS_GUI_SortPack4 = CreateFrame("Frame", "LPS_GUI_SortPack4", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortPack4, LPS_GUI_ChangeSortPack4, LPS_Config.pack4, LPS_GUI_SortTypes);
	LPS_GUI_SortPack4:SetPoint("TOPLEFT", LPS_GUI_SortPack3, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortPack4, "Pack 4 Sort Style -");

--[[
	Need to put a header in here somehow
	
	Options below are for the bank.
	
	]]

	-- Sort Style for Bank
	LPS_GUI_SortBankPack0 = CreateFrame("Frame", "LPS_GUI_SortBankPack0", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack0, LPS_GUI_ChangeSortBankPack0, LPS_Config.packb0, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack0:SetPoint("TOPLEFT", LPS_GUI_SortPack4, "TOPLEFT", 0, -50);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack0, "Main Bank Window Sort Style -");

	-- Sort Style for Bank Bag 1
	LPS_GUI_SortBankPack1 = CreateFrame("Frame", "LPS_GUI_SortBankPack1", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack1, LPS_GUI_ChangeSortBankPack1, LPS_Config.packb1, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack1:SetPoint("TOPLEFT", LPS_GUI_SortBankPack0, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack1, "Bank Bag 1 Sort Style -");

	-- Sort Style for Bank Bag 2
	LPS_GUI_SortBankPack2 = CreateFrame("Frame", "LPS_GUI_SortBankPack2", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack2, LPS_GUI_ChangeSortBankPack2, LPS_Config.packb2, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack2:SetPoint("TOPLEFT", LPS_GUI_SortBankPack1, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack2, "Bank Bag 2 Sort Style -");

	-- Sort Style for Bank Bag 3
	LPS_GUI_SortBankPack3 = CreateFrame("Frame", "LPS_GUI_SortBankPack3", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack3, LPS_GUI_ChangeSortBankPack3, LPS_Config.packb3, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack3:SetPoint("TOPLEFT", LPS_GUI_SortBankPack2, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack3, "Bank Bag 3 Sort Style -");

	-- Sort Style for Bank Bag 4
	LPS_GUI_SortBankPack4 = CreateFrame("Frame", "LPS_GUI_SortBankPack4", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack4, LPS_GUI_ChangeSortBankPack4, LPS_Config.packb4, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack4:SetPoint("TOPLEFT", LPS_GUI_SortBankPack3, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack4, "Bank Bag 4 Sort Style -");

	-- Sort Style for Bank Bag 5
	LPS_GUI_SortBankPack5 = CreateFrame("Frame", "LPS_GUI_SortBankPack5", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack5, LPS_GUI_ChangeSortBankPack5, LPS_Config.packb5, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack5:SetPoint("TOPLEFT", LPS_GUI_SortBankPack4, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack5, "Bank Bag 5 Sort Style -");

	-- Sort Style for Bank Bag 6
	LPS_GUI_SortBankPack6 = CreateFrame("Frame", "LPS_GUI_SortBankPack6", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack6, LPS_GUI_ChangeSortBankPack6, LPS_Config.packb6, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack6:SetPoint("TOPLEFT", LPS_GUI_SortBankPack5, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack6, "Bank Bag 6 Sort Style -");

	-- Sort Style for Bank Bag 7
	LPS_GUI_SortBankPack7 = CreateFrame("Frame", "LPS_GUI_SortBankPack7", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortBankPack7, LPS_GUI_ChangeSortBankPack7, LPS_Config.packb7, LPS_GUI_SortTypes);
	LPS_GUI_SortBankPack7:SetPoint("TOPLEFT", LPS_GUI_SortBankPack6, "TOPLEFT", 0, -30);
	LGUI_AddDescLeft(LPS_GUI_SortBankPack7, "Bank Bag 7 Sort Style -");


--[[
	Need to put a header in here somehow
	
	Options below are for the bank.
	
	]]

	-- Sort Style for Guild Bank Slot
	LPS_GUI_SortGuildBank = CreateFrame("Frame", "LPS_GUI_SortGuildBank", LPS_GUI_OPTIONS_SC, "UIDropDownMenuTemplate");
	LGUI_DropDown(LPS_GUI_SortGuildBank, LPS_GUI_ChangeSortGuildBank, LPS_Config.guild, LPS_GUI_SortTypes);
	LPS_GUI_SortGuildBank:SetPoint("TOPLEFT", LPS_GUI_SortBankPack7, "TOPLEFT", 0, -50);
	LGUI_AddDescLeft(LPS_GUI_SortGuildBank, "Guild Bank Sort Style -");


end

function LPS_GUI_ChangeSortDirection()
	if (LPS_Config.lowestfirst == false) then
		LPS_Config.lowestfirst = true;
	else
		LPS_Config.lowestfirst = false;
	end
end

-- Various button functions
function LPS_GUI_SBItemsPackSelect(selection)
	LPS_Config.sbitemPack = (selection - 2);
end

function LPS_GUI_QuestItemsPackSelect(selection)
	LPS_Config.questPack = (selection - 2);
end

function LPS_GUI_ChangeHerbSort(selection)
	LPS_Config.herbsort = (selection - 2);
end

function LPS_GUI_ChangeLeatherSort(selection)
	LPS_Config.leathersort = (selection - 2);
end

function LPS_GUI_ChangeClothSort(selection)
	LPS_Config.clothsort = (selection - 2);
end

function LPS_GUI_ChangeMineralSort(selection)
	LPS_Config.mineralsort = (selection - 2);
end

function LPS_GUI_ChangeConsumableSort(selection)
	LPS_Config.consumablesort = (selection - 2);
end

function LPS_GUI_ChangeTradeSort(selection)
	LPS_Config.tradesort = (selection - 2);
end

function LPS_GUI_ChangeGemSort(selection)
	LPS_Config.gemsort = (selection - 2);
end

function LPS_GUI_ChangeCustomSort1(selection)
	LPS_Config.customsort1 = (selection - 2);
end

function LPS_GUI_ChangeCustomSort2(selection)
	LPS_Config.customsort2 = (selection - 2);
end

function LPS_GUI_ChangeSortKeyRing(selection)
	LPS_Config.keyring = (selection - 1);
end

function LPS_GUI_ChangeSortPack0(selection)
	LPS_Config.pack0 = (selection - 1);
end

function LPS_GUI_ChangeSortPack1(selection)
	LPS_Config.pack1 = (selection - 1);
end

function LPS_GUI_ChangeSortPack2(selection)
	LPS_Config.pack2 = (selection - 1);
end

function LPS_GUI_ChangeSortPack3(selection)
	LPS_Config.pack3 = (selection - 1);
end

function LPS_GUI_ChangeSortPack4(selection)
	LPS_Config.pack4 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack0(selection)
	LPS_Config.packb0 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack1(selection)
	LPS_Config.packb1 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack2(selection)
	LPS_Config.packb2 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack3(selection)
	LPS_Config.packb3 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack4(selection)
	LPS_Config.packb4 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack5(selection)
	LPS_Config.packb5 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack6(selection)
	LPS_Config.packb6 = (selection - 1);
end

function LPS_GUI_ChangeSortBankPack7(selection)
	LPS_Config.packb7 = (selection - 1);
end

function LPS_GUI_ChangeSortGuildBank(selection)
	LPS_Config.guild = (selection - 1);
end
